package topin.facecat.FaceCat.Product.UI

import facecat.topin.core.FCColor
import facecat.topin.core.FCNative
import java.util.*


class MyColor {
    var m_lastStyle = -1
    var m_userColors =
        HashMap<Long, Long?>()

    fun createColors() {
        m_userColors.clear()
        if (m_style == 1) {
            m_userColors[FCColor.Back] = FCColor.rgb(255, 255, 255) //1
            m_userColors[FCColor.Border] = FCColor.rgb(200, 200, 200) //1
            m_userColors[FCColor.Text] = FCColor.rgb(0, 0, 0) //1
            m_userColors[FCColor.DisabledBack] = FCColor.rgba(0, 0, 0, 25) //1
            m_userColors[FCColor.DisabledText] = 3289650L
            m_userColors[FCColor.Hovered] = FCColor.rgba(43, 138, 195, 150)
            m_userColors[FCColor.Pushed] = FCColor.rgba(43, 138, 195, 100)
        } else {
            m_userColors[FCColor.Back] = 1709331L
            m_userColors[FCColor.Border] = 3289650L
            m_userColors[FCColor.Text] = 16777215L
            m_userColors[FCColor.DisabledBack] = -16777215025L
            m_userColors[FCColor.DisabledText] = 3289650L
            m_userColors[FCColor.Hovered] = -12814891150L
            m_userColors[FCColor.Pushed] = -12814891100L
        }
        m_myColors.clear()
    }

    fun getUserColor(color: Long): Long {
        var color = color
        if (m_lastStyle != m_style) {
            m_lastStyle = m_style
            createColors()
        }
        if (m_myColors.containsKey(color)) {
            color = m_myColors[color]!!
        } else {
            if (m_userColors.containsKey(color)) {
                color = m_userColors[color]!!
            }
        }
        return color
    }

    companion object {
        var m_systemFont = ""

        var systemFont: String
            get() {
                if (m_systemFont.length == 0) {
                    m_systemFont = "System"
                }
                return m_systemFont
            }
            set(value) {
                m_systemFont = value
                FCNative.addChangeID()
            }

        var m_style = 0
        var m_myColors =
            HashMap<Long, Long?>()

        fun setStyle(value: Int) {
            m_style = value
        }
    }
}